package thread;

public class Demo19 {
    public static void main(String[] args) {
        Object locker1 = new Object();
        Thread t1 = new Thread(()->{
           synchronized(locker1) {
               try {
                   locker1.wait();
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
           System.out.println("t1被唤醒了");
        });
        Thread t2 = new Thread(()->{
           synchronized (locker1){
               try {
                   locker1.wait(5000);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
           }
           System.out.println("t2被唤醒");
        });
        Thread t3 = new Thread(()->{
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            synchronized (locker1){
               locker1.notifyAll();
           }
        });
        t1.start();
        t2.start();
        t3.start();

    }
}
